home *** CD-ROM | disk | FTP | other *** search
/ Windows Game Programming for Dummies (2nd Edition) / WinGamProgFD.iso / mac / DirectX SDK / DXSDK / samples / Multimedia / VBSamples / DirectSound / Tutorials / Tut1 / audtut1.frm next >
Text File  |  2001-10-08  |  4KB  |  130 lines

  1. VERSION 5.00
  2. Begin VB.Form frmAudTut1 
  3.    Caption         =   "Audio Tutorial 1"
  4.    ClientHeight    =   1320
  5.    ClientLeft      =   60
  6.    ClientTop       =   345
  7.    ClientWidth     =   5460
  8.    Icon            =   "audtut1.frx":0000
  9.    LinkTopic       =   "Form1"
  10.    ScaleHeight     =   1320
  11.    ScaleWidth      =   5460
  12.    StartUpPosition =   3  'Windows Default
  13.    Begin VB.CommandButton cmdClose 
  14.       Caption         =   "Close"
  15.       Default         =   -1  'True
  16.       Height          =   375
  17.       Left            =   4260
  18.       TabIndex        =   0
  19.       Top             =   900
  20.       Width           =   1035
  21.    End
  22.    Begin VB.Image Image1 
  23.       Height          =   480
  24.       Left            =   120
  25.       Picture         =   "audtut1.frx":0442
  26.       Top             =   120
  27.       Width           =   480
  28.    End
  29.    Begin VB.Label lbl 
  30.       BackStyle       =   0  'Transparent
  31.       Caption         =   "Copyright (C) 1999-2001 Microsoft Corporation, All Rights Reserved."
  32.       Height          =   255
  33.       Index           =   2
  34.       Left            =   600
  35.       TabIndex        =   3
  36.       Top             =   300
  37.       Width           =   4800
  38.    End
  39.    Begin VB.Label lbl 
  40.       BackStyle       =   0  'Transparent
  41.       Caption         =   "GM/GS« Sound Set Copyright ⌐1996, Roland Corporation U.S."
  42.       Height          =   255
  43.       Index           =   1
  44.       Left            =   600
  45.       TabIndex        =   2
  46.       Top             =   540
  47.       Width           =   4755
  48.    End
  49.    Begin VB.Label lbl 
  50.       BackStyle       =   0  'Transparent
  51.       Caption         =   "DirectMusic Segment Tutorial"
  52.       Height          =   255
  53.       Index           =   0
  54.       Left            =   600
  55.       TabIndex        =   1
  56.       Top             =   60
  57.       Width           =   2655
  58.    End
  59. End
  60. Attribute VB_Name = "frmAudTut1"
  61. Attribute VB_GlobalNameSpace = False
  62. Attribute VB_Creatable = False
  63. Attribute VB_PredeclaredId = True
  64. Attribute VB_Exposed = False
  65. '''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''
  66. '
  67. '  Copyright (C) 1999-2001 Microsoft Corporation.  All Rights Reserved.
  68. '
  69. '  File:       audTut1.frm
  70. '
  71. '''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''
  72. Option Explicit
  73. ' Our DX variables
  74. Private dx As New DirectX8
  75. 'We need a loader variable
  76. Private dml As DirectMusicLoader8
  77. 'We need our performance object
  78. Private dmp As DirectMusicPerformance8
  79. 'We also need our DMusic segment
  80. Private seg As DirectMusicSegment8
  81.  
  82. Private Sub cmdClose_Click()
  83.     Unload Me
  84. End Sub
  85.  
  86. Private Sub Form_Load()
  87.     Dim dmA As DMUS_AUDIOPARAMS
  88.     'Get our loader and performance
  89.     Set dml = dx.DirectMusicLoaderCreate
  90.     Set dmp = dx.DirectMusicPerformanceCreate
  91.     
  92.     'We will put in error checking here in case we can't init DMusic
  93.     'ie, if there is no sound card
  94.     On Error GoTo FailedInit
  95.     'Initialize our DMusic Audio with a default environment
  96.     dmp.InitAudio Me.hWnd, DMUS_AUDIOF_ALL, dmA, Nothing, DMUS_APATH_SHARED_STEREOPLUSREVERB, 64
  97.     
  98.     'Here we will load our audio file.  We could load a wave file,
  99.     'a midi file, and rmi file, or a DMusic segment.  For this
  100.     'tutorial we will load a segment.
  101.     
  102.     'Before we load our segment, set our search directory
  103.     dml.SetSearchDirectory FindMediaDir("sample.sgt")
  104.     'Now we can load our segment
  105.     Set seg = dml.LoadSegment("sample.sgt")
  106.     'Download our segment to the default audio path (created during our call to InitAudio)
  107.     seg.Download dmp.GetDefaultAudioPath
  108.     'Play our segment from the beginning
  109.     dmp.PlaySegmentEx seg, 0, 0
  110.     Exit Sub
  111.     
  112. FailedInit:
  113.     MsgBox "Could not initialize DirectMusic." & vbCrLf & "This sample will exit.", vbOKOnly Or vbInformation, "Exiting..."
  114.     Unload Me
  115. End Sub
  116.  
  117. Private Sub Form_Unload(Cancel As Integer)
  118.     On Error Resume Next
  119.     'Stops everything playing on the audio path
  120.     dmp.StopEx dmp.GetDefaultAudioPath, 0, 0
  121.     'Destroy all of our objects
  122.     Set seg = Nothing
  123.     'Closedown the performance object (we should always do this).
  124.     dmp.CloseDown
  125.     'Destroy the rest of our objects
  126.     Set dmp = Nothing
  127.     Set dml = Nothing
  128.     Set dx = Nothing
  129. End Sub
  130.